package base.day26.tcp;

import java.io.*;
import java.net.Socket;

public class SendDemo3 {
    public static void main(String[] args) throws IOException {
        Socket socket=new Socket("127.0.0.1",20000);
        //读取本地流
        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("C:\\Users\\SuperJohn\\Desktop\\abc.txt"));

        //网络中的流
        OutputStream os = socket.getOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(os);
        int b;
        while ((b=bis.read())!=-1){
            bos.write(b);
        }
        socket.shutdownOutput();

        BufferedReader bw=new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String str;
        while ((str=bw.readLine())!=null){
            System.out.println(str);
        }
        bis.close();
        //socket.close();
    }
}
